import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import { unstable_HistoryRouter as HistoryRouter } from 'react-router-dom'
import { ConfigCtxProvider } from '@/context/config'
import { GlobalConstant } from '@/library/constants/globalConstant'
import { BASE_NAME } from '@/library/tool-kits/get-process-env'
import { printBaseInfo } from '@/library/tool-kits/log'
import { history } from '@/common/history'
import App from '@/App'
import '@/library/libs/i18n'
import './global.scss'

printBaseInfo('欢迎使用RT', '0.0.1')

const root = document.querySelector('#root')

const renderPackApp = () => (
  // <StrictMode>
  <ConfigCtxProvider
    language={localStorage.getItem(GlobalConstant.LANGUAGE)!}
  >
    <HistoryRouter
      basename={BASE_NAME}
      history={history}
    >
      <App />
    </HistoryRouter>
  </ConfigCtxProvider>
  // </StrictMode>
)

if (root) {
  createRoot(root).render(renderPackApp())
}
